package com.thon.entity.user;

// Generated 2013-9-23 19:12:56 by Hibernate Tools 3.4.0.CR1

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.thon.entity.project.Product;
import com.thon.entity.project.Project;
import com.thon.entity.util.IdEntity;

/**
 * MeFundDetail generated by hbm2java
 */
@Entity
@Table(name = "fund_details")
@JsonIgnoreProperties(ignoreUnknown = true)
public class FundDetail extends IdEntity {

	private static final long serialVersionUID = -2698868530610612322L;
	private User user;
	private Project project;
	private Product product;
	private Integer amount;
	private Date createdDate;
	private Integer remainingSum;
    private String account;
    private String realName;
    private Integer payType;
    private String bank;
    private String phone;
    
	public Integer getPayType() {
		return payType;
	}

	public void setPayType(Integer payType) {
		this.payType = payType;
	}

	public String getBank() {
		return bank;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	/*
	 * 1充值
	 * 0支出
	 * 3生成订单
	 */
	private Integer actionType;
	private String tradeNo;

	public Integer getRemainingSum() {
		return remainingSum;
	}

	public void setRemainingSum(Integer remainingSum) {
		this.remainingSum = remainingSum;
	}
	public FundDetail() {
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "project_id")
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	public Project getProject() {
		return this.project;
	}

	public void setProject(Project project) {
		this.project = project;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "product_id")
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	public Product getProduct(){
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}	
	


	public Integer getAmount() {
		return this.amount;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Integer getActionType() {
		return actionType;
	}

	public void setActionType(Integer actionType) {
		this.actionType = actionType;
	}

	@Transient
	public String getUserName() {
		return user.getName();
	}

	@Transient
	@JsonIgnore//去掉充值报错
	public String getProjectName() {
		try {
			return project.getName();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public String getTradeNo() {
		return tradeNo;
	}

	public void setTradeNo(String tradeNo) {
		this.tradeNo = tradeNo;
	}

}
